#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=120;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][maxn];
LL n;
LL cnt1=0,cnt2=0;
LL get(){
   LL col;cin>>col;
   return col;
}
void solve1(LL col){
    if(col==1){
        for(LL j=1;j<=n;j++){
              for(LL k=1;k<=n;k++){
                 if(!a[j][k]&&((j+k)%2==0)){
                    a[j][k]=1;cnt1++;
                    cout<<col<<" "<<j<<" "<<k<<endl;
                    return;
                 }
              }
        }
    }
    else if(col==2){
        for(LL j=1;j<=n;j++){
            for(LL k=1;k<=n;k++){
                if(!a[j][k]&& ( (j+k)&1)){
                    a[j][k]=2;cnt2++;
                    cout<<col<<" "<<j<<" "<<k<<endl;
                    return;
                }
            }
        }
    }
    else if(col==3){
        for(LL j=1;j<=n;j++){
            for(LL k=1;k<=n;k++){
                if(!a[j][k]){
                    a[j][k]=3;
                    cout<<col<<" "<<j<<" "<<k<<endl;
                    return;
                }
            }
        }
    }
}
int main(void){
    cin>>n;
    for(LL i=1;i<=n*n;i++){
        LL col=get();
        LL temp1=n*n/2-cnt1;
        if(n&1) temp1++;
        LL temp2=n*n/2-cnt2;
        if(col==3){
           if(temp1){
              solve1(1);
           }
           else if(temp2){
              solve1(2);
           }
           else solve1(3);
        }
        if(col==1){
            if(temp2){
                solve1(2);
            }
            else{
                cnt1++;solve1(3);
            }
        }
        if(col==2){
            if(temp1){
                solve1(1);
            }
            else{
                cnt2++;solve1(3);
            }
        }
   }
   return 0;
}
